﻿<?php include("template/baglanti.php"); include ("./upload.php"); include("template/header.php"); ?>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<?php

$id = intval($_GET['id']);
$ctID = intval($_GET['ctID']);
$ok = "";
$save = $_POST['save'];

if ($save) {



//Konu Ekleme Alanı


$Phctid = $_POST['ctID'];
$Phid = $_POST['id'];
$Phname = $_POST['Phname'];
$Phinfo = $_POST['Phinfo'];
$Phinfocn = $_POST['Phinfocn'];
$Phshow = $_POST['Phshow'];


$dosyasmall = $_FILES['dosyasmall'];
if ( $dosyasmall['name'] != '') {
$Phsphoto = upload_pic($dosyasmall);
}

$dosya = $_FILES['dosya'];
if ( $dosya['name'] != '') {
$Phphoto = upload_pic($dosya);
}


@mysql_query("insert into photogaleri
(`categori_id`, `PdID`, `Phname`, `Phinfo`,  `Phinfocn`, `Phsphoto` , `Phphoto` , `Pdshow` )
values ('$Phctid', '$Phid', '$Phname', '$Phinfo', '$Phinfocn',   '$Phsphoto', '$Phphoto' , '$Phshow' )");

$ok = "done";
}

if(!$ok) {

?>

<div class="clear"> </div>

<div class="wrapper">

<div class="menu radius flt">
<?php include("./template/menu.php") ?>
</div>



<div class="wrapperInside radius flt">


<div class="wrapperInsideCapture"> Anatolia Deco Products Add</div>

<div class="wpForm">

<form class="validate" name="form1" method="post" id="save" enctype="multipart/form-data" >


	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Category and Sub Category Name</div>
	<div class="wpFormText radius"> 

	<?php

		$cns = ("SELECT * FROM `categori` WHERE `categori_id` = '$ctID' ");
		$cn = mysql_query($cns);
		$cnl = mysql_fetch_assoc($cn);
		$pns = ("SELECT * FROM `products` WHERE `PdID` = '$id' ");
		$pn = mysql_query($pns);
		$pnl = mysql_fetch_assoc($pn);
		
	?>

	<input type="text" value="<?=$cnl['categori_name']?> I <?=$pnl['Pdname']?>" readonly >

	</div>
	</div>



	






<div class="wpFormLabelBox">
<div class="wpFormLabel"> Prodcut Name</div>
<div class="wpFormText radius"> <input name="Phname" type="text"></div>
</div>






<div class="wpFormLabelBox">
<div class="wpFormLabel "> Product Information</div>
<div class="wpFormText" style="display:block; height:100%;">
<textarea name="Phinfo" id="textarea" cols="45"rows="5" /  class="mceEditor" ></textarea>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormLabel "> Product Chinese Information</div>
<div class="wpFormText" style="display:block; height:100%;">
<textarea name="Phinfocn" id="textarea" cols="45"rows="5" /  class="mceEditor" ></textarea>
</div>
</div>



<div class="wpFormLabelBox">
<div class="wpFormLabel"> Small Photo (250x250px)</div>
<input type="file" class="nicefileinput wpFormUpload" name="dosyasmall" id="fileField" />
</div>

<div class="wpFormLabelBox">
<div class="wpFormLabel"> Big Photo (800x800px)</div>
<input type="file" class="nicefileinput wpFormUpload" name="dosya" id="fileField" />

</div>






<div class="wpFormLabelBox">
<div class="wpFormLabel">Sayfada Göster</div>
<div class="wpFormCheck">
<input id="radio1" type="radio" name="Phshow" value="1" > <label> Yes </label>
<input id="radio1" type="radio" name="Phshow" value="0" style="margin-left:24px;"> <label> No</label>
</div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormButton"><input type="submit" name="save" id="save" value="save" class="radius"></div>
</div>


</form>



</div>

<?php } if ($ok == "done"): ?>
<div class="welldone"><img src="images/ok.jpg" width="300" height="300"><br>
Kayıt İşleminiz Tamamlandı<br><a href="products.php">:: OK :: </a> </div>
<?php endif; ?>
</div>
</div>


<?php include("template/footer.php") ?>

<?php

function upload_pic($file)
{
$upload = new upload($file);
$new_name = substr(md5(time()),0,6).substr(md5(rand(0,100000)),0,6);
#big
$upload->file_new_name_body = $new_name;
$upload->process('./upload/pt/');
if($upload->processed){
$upload->clean();
return $new_name.'.jpg';
}
return 'Hata:'.$upload->error;
}
?>

